package com.LFLWZ.ServiceImpl;

import com.LFLWZ.beans.Dto.Page;
import com.LFLWZ.beans.POJO.*;
import com.LFLWZ.beans.Vo.ClassroomCourseVo;
import com.LFLWZ.beans.Vo.CommentsVo;
import com.LFLWZ.beans.Vo.LecturerAndCloudLogin;
import com.LFLWZ.mapper.*;
import com.LFLWZ.service.worksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Reference;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class worksServiceImpl {

    @Autowired
    private worksMapper worksMapper;
    @Autowired
    private ShowPageMapper showPageMapper;
    @Autowired
    private CloudLoginmapper cloudLoginmapper;
    @Autowired
    private CommentsMapper commentsMapper;
    /**
     * 查询后台待审核的作品
     * @param worksshow
     * @return
     */
    public List<Worksshow> list(Worksshow worksshow){
        System.out.println(worksshow.getAudit());
        return worksMapper.selWorks(worksshow);
    }

    /**
     * 修改用户审核状态
     * @param worksshow
     * @return
     */
    public int update(Worksshow worksshow){
        return worksMapper.update(worksshow);
    }

    /**
     * 查询后台待审核讲师信息
     */
       public List<LecturerApply> selLecturer(LecturerApply lecturerApply){
          return  worksMapper.selLecturer(lecturerApply);
       }
    /**
     * 修改审核状态通过
     */
    public int updAudit(LecturerApply lecturerApply){
        return worksMapper.updAudit(lecturerApply);
    }
    /**
     * 轮播图显示
     */
    public List<ShowPage> queryrotation(int offset, int limit) {
        return showPageMapper.queryrotation(null);
    }
    /**
     * 菜单显示
     * @param offset
     * @param limit
     * @return
     */public List<ShowPage> querymenu(int offset, int limit) {
        return showPageMapper.querymenu(null);
    }
    /**
     * 用户列表显示
     */
    public List<ShowPage> querylist(int offset, int limit) {
        return showPageMapper.querylist(null);
    }
/**
 * 修改状态改变权限
 */
    public int updStatus(ShowPage showPage){
        return showPageMapper.updStatus(showPage);
    }
    /**
     * 轮播图修改
     */
    public int updater(ShowPage showPage){
        return  showPageMapper.updater(showPage);
    }
    /**
     * 轮播图插入
     */
    public int inst(ShowPage showPage){return showPageMapper.inst(showPage);}
    /**
     * 轮播图删除
     */
    public int delt(Integer id){
        return showPageMapper.delt(id);
    }
    /**
     * 轮播图删除
     */
    public int upda(ShowPage showPage) {
        return showPageMapper.upda(showPage);
    }
    /***
     * 查询所有讲师
     * @param lecturer 讲师 实体类
     * @return
     */
    public List<Lecturer> selall(Lecturer lecturer){
        return worksMapper.selall(lecturer);
    }

    /***
     * 查询讲师类型
     * @param excellent
     * @return
     */
    public List<Lecturer> selexc(Integer excellent){
        return worksMapper.selexc(excellent);
    }

    /***
     * 根据姓名查询讲师
     * @param
     * @return
     */
    public List<LecturerAndCloudLogin> Lsel(LecturerAndCloudLogin lecturerAndCloudLogin){
        return worksMapper.Lsel(lecturerAndCloudLogin);
    }

    /***
     * 添加讲师(讲师管理)
     */
    public int inslecturer(Lecturer lecturer){
        return worksMapper.inslecturer(lecturer);
    }

    /***
     * 修改讲师(讲师管理)
     */
    public int upData(Lecturer lecturer){
        return worksMapper.upData(lecturer);
    }

    /***
     * 根据ID删除数据
     */
    public int del(Integer id){
        return worksMapper.del(id);
    }

    /***
     * 查询专栏(课程专栏)
     */
    public List<Column> selCol(Column column){
        return worksMapper.selCol(column);
    }

    /***
     * 查询专栏(课程专栏)
     */
    public int insCol(Column column){
        return worksMapper.insCol(column);
    }

    /***
     * 修改专栏(课程专栏)
     */
    public int upCol(Column column){
        return worksMapper.upCol(column);
    }

    /***
     * 删除专栏(课程专栏)
     */
    public int delCol(Integer id){
        return worksMapper.delCol(id);
    }

    /**
     * 课程
     * @param classroomCourseVo
     * @return
     */
    public List<ClassroomCourseVo> selClass(ClassroomCourseVo classroomCourseVo){
        return worksMapper.selClass(classroomCourseVo);
    }

    /***
     * 新增用户
     * @param
     * @return
     */
    public int insLogin(CloudLogin cloudLogin){
       return worksMapper.insLogin(cloudLogin);
    }

    /***
     * 关联系统用户添加
     */
    public int insLink(CloudLogin cloudLogin){
        return worksMapper.insLink(cloudLogin);
    }
    /***
     * 查询用户UID
     */
    public List<CloudLogin> selUid(CloudLogin cloudLogin){
        return worksMapper.selUid(cloudLogin);
    }
    /***
     * 查询讲师UID
     */
    public List<Lecturer> selLeUid(Lecturer lecturer){
        return worksMapper.selLeUid(lecturer);
    }
    /**
     * 查询所有用户信息
     */
    public List<CloudLogin> loginsel(CloudLogin cloudLogin){
        return cloudLoginmapper.queryAll(cloudLogin);
    }
    /**
     * 修改用戶信息
     */
    public int updlogin(CloudLogin cloudLogin){
        return cloudLoginmapper.updlogin(cloudLogin);
    }
    /**
     * 查询所有课程评论
     */
    public Page<CommentsVo> queryLesson(CommentsVo commentsVo){
        commentsVo.setOffset((commentsVo.getPage()-1)*commentsVo.getLimit());
        Page page=new Page<>();
        page.setTotal(commentsMapper.getCount());
        page.setRows(commentsMapper.queryLesson(commentsVo));
        return page;
    }
    /**
     * 查询所有章节评论
     */
    public Page<CommentsVo> querySection(CommentsVo commentsVo){
        commentsVo.setOffset((commentsVo.getPage()-1)*commentsVo.getLimit());
        Page page=new Page<>();
        page.setTotal(commentsMapper.getCount1());
        page.setRows(commentsMapper.querySection(commentsVo));
        return page;
    }
    /**
     * 查询所有课程评论
     */
    public Page<CommentsVo> queryDW(CommentsVo commentsVo){
        commentsVo.setOffset((commentsVo.getPage()-1)*commentsVo.getLimit());
        Page page=new Page<>();
        page.setTotal(commentsMapper.getCount2());
        page.setRows(commentsMapper.queryDW(commentsVo));
        return page;
    }
    public List<Lecturer> selBy(Lecturer lecturer){
        return worksMapper.selBy(lecturer);
    }
}
